<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../static/css/common.css">
    <link rel="stylesheet" href="../static/css/main.css">
    <link rel="stylesheet" href="../static/css/iconfont.css">
    <link rel="stylesheet" href="../static/layui/css/layui.css">
    <script src="../static/js/jquery-3.3.1.js"></script>
    <title>Update</title>
</head>
<body>
<script type="text/javascript">
    $(function () {
        $("#submit").click(function () {
            var oldpwd = $("#oldpwd").val();
            var newpwd = $("#newpwd").val();
            var repwd = $("#repwd").val();
            var t_id = $("#t_id").val();
            if (newpwd!=repwd){
                alert("新旧密码不同!")
                return false;
            }
            $.ajax({
                type: "post",
                url: "/teacher/doUpdate",
                data: {
                    oldpwd : oldpwd,
                    newpwd : newpwd,
                    tid : t_id

                },
                success:function (data) {
                    if(data=="1"){
                        window.location.href = "../teacher/returnLogin"
                    }
                    if (data=="原密码错误"){
                        alert("原密码错误")
                    }
                },
                error:function (data) {
                    alert("ajax error")
                }

            })
        })
    })
</script>
<input type="hidden" id="t_id" th:value="${session.teacher.getT_id()}">
<div class="main-wrap" style="margin-left: 10px;">
    <div class="result-wrap">
        <table action="" method="post" id="myform" name="myform">
            <div class="config-items">

                <h1><span class="iconfont glyphicon-book">网站信息设置</span></h1>

                <div class="config-title">
                    <!--            -->
                </div>
                <div class="result-content">
                    <table width="100%" class="insert-tab">
                        <tbody>
                        <tr>
                            <th width="15%">原密码:</th>
                            <td><input id="oldpwd" type="password" value="" size="85"
                                       name="keywords" class="common-text"></td>
                        </tr>
                        <tr>
                            <th>新密码：</th>
                            <td><input id="newpwd" type="password" value="" size="85"
                                       name="title" class="common-text"></td>
                        </tr>
                        <tr>
                            <th>确认新密码:</th>
                            <td><input type="password" id="repwd"
                                       value=""
                                       size="85" name="keywords" class="common-text"></td>
                        </tr>
                        <tr>
                            <th></th>
                            <td>
                                <input type="button" id="submit" value="提交" class="btn btn-primary btn6 mr10">
                                <input type="button" value="返回" onClick="history.go(-1)"
                                       class="btn btn6">
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </table>
    </div>
</div>
</body>
</html>